package me.softwareengineer.guice.rendering.domain;

import java.util.Map;

import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.OnVerbatimEvent;

/**
 * Represents not-interpreted in-line sequence of characters which should be
 * represented in the final text "as is".
 * 
 * @author yadtahir
 * 
 *         <pre>
 * This class is thread-safe and can be cached/re-used and used concurrently.
 * </pre>
 */
public class VerbatimElement extends Element {
	/**
	 * The string to protect from rendering.
	 */
	private final String protectedString;
	

	/**
	 * If true the element is located in a inline content (like paragraph,
	 * etc.).
	 */
	private final boolean isInline;
	

	/**
	 * @param protectedString
	 *            the string to protect from rendering.
	 * @param isInline
	 *            if true the macro is located in a inline content (like
	 *            paragraph, etc.).
	 */
	public VerbatimElement(String protectedString, boolean isInline) {
		this.protectedString = protectedString;
		this.isInline = isInline;
	}

	/**
	 * @param protectedString
	 *            the string to protect from rendering.
	 * @param properties
	 *            the custom properties of the element
	 * @param isInline
	 *            if true the macro is located in a inline content (like
	 *            paragraph, etc.).
	 */
	public VerbatimElement(String protectedString,
			Map<String, String> properties, boolean isInline) {
		super(properties);

		this.protectedString = protectedString;
		this.isInline = isInline;
	}

	/**
	 * @return the string to protect from rendering
	 * <p>
	 * This property is immutable and thread-safe
	 * </p>
	 */
	public String getProtectedString() {
		
			return this.protectedString;
	

	}

	/**
	 * @return if true the macro is located in a inline content (like paragraph,
	 *         etc.).
	 * <p>
	 * This property is immutable and thread-safe
	 * </p>
	 */
	public boolean isInline() {
	
			return this.isInline;
		

	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void render(Listener l) {
		OnVerbatimEvent e = new OnVerbatimEvent(getProtectedString(),
				getAllProperties(), isInline());
		l.onEvent(e);
	}

	
}
